//
//  MovieDetailView.m
//  UI-豆瓣项目APP
//
//  Created by dllo on 15/10/28.
//  Copyright © 2015年 孙鹏. All rights reserved.
//

#import "MovieDetailView.h"
#import "UIImageView+WebCache.h"
@implementation MovieDetailView

-(instancetype)initWithFrame:(CGRect)frame
{
    
    
    self = [super initWithFrame:frame];
    if (self) {
        
        
        [self creatSubviews];
        
    }
    
    return self;
}


- (void)creatSubviews
{
    
    
    self.headImage = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 120, 170)];
    [self.headImage setImage:[UIImage imageNamed:@"5"]];
    [self addSubview:self.headImage];
    [self.headImage release];
    
    
    
    self.grade = [[UILabel alloc]initWithFrame:CGRectMake(210, 30, 30, 30)];
    self.grade.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.grade];
    [self.grade release];
    
  
    self.grade.font = [UIFont systemFontOfSize:15];
    self.grade.numberOfLines = 0;
    
    
    self.grade1 = [[UILabel alloc]initWithFrame:CGRectMake(170, 30, 40, 30)];
    self.grade1.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.grade1];
    [self.grade1 release];
    
    self.grade1.text = @"评分:";
    self.grade1.font = [UIFont systemFontOfSize:15];
//    self.grade1.numberOfLines = 0;
    
    
    self.rating_count = [[UILabel alloc]initWithFrame:CGRectMake(250, 30, 100, 30)];
    self.rating_count.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.rating_count];
    [self.rating_count release];
    
  
    self.rating_count.numberOfLines = 0;
    self.rating_count.font = [UIFont systemFontOfSize:15];
    
    self.data = [[UILabel alloc]initWithFrame:CGRectMake(170, 60, 200, 30)];
    self.data.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.data];
    [self.data release];
    
   
    self.data.font = [UIFont systemFontOfSize:15];
    self.data.numberOfLines = 0;
    
    
    self.runtime = [[UILabel alloc]initWithFrame:CGRectMake(170, 90, 200, 30)];
    self.runtime.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.runtime];
    [self.runtime release];
    
    
    self.runtime.font = [UIFont systemFontOfSize:15];
    self.runtime.numberOfLines = 0;
    
    
    self.genres = [[UILabel alloc]initWithFrame:CGRectMake(170, 120, 200, 30)];
    self.genres.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.genres];
    [self.genres release];
    
   
    self.genres.font = [UIFont systemFontOfSize:15];
    self.genres.numberOfLines = 0;
    
    self.country = [[UILabel alloc]initWithFrame:CGRectMake(170, 150, 200, 30)];
    self.country.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.country];
    [self.country release];
    
   
    self.country.font = [UIFont systemFontOfSize:15];
    self.country.numberOfLines = 0;
    
    
    self.actors1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 220, 200, 30)];
    self.actors1.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.actors1];
    [self.country release];
    
    self.actors1.text = @"制作人";
    self.actors1.font = [UIFont systemFontOfSize:20];
    self.actors1.font = [UIFont boldSystemFontOfSize:20];
    self.actors1.numberOfLines = 0;
    
    
    
    
    self.actors = [[UILabel alloc]initWithFrame:CGRectMake(20, 260, 350, 80)];
    self.actors.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.actors];
    [self.actors release];
    

    self.actors.font = [UIFont systemFontOfSize:15];
    self.actors.numberOfLines = 0;
    
    
    self.introduce = [[UILabel alloc]initWithFrame:CGRectMake(20, 330, 200, 30)];
    self.introduce.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.introduce];
    [self.introduce release];
    
    self.introduce.text = @"电影情节";
    self.introduce.font = [UIFont systemFontOfSize:20];
    self.introduce.font = [UIFont boldSystemFontOfSize:20];
    self.introduce.numberOfLines = 0;
    
    
    
    
    
    self.plot = [[UILabel alloc]initWithFrame:CGRectMake(20, 360, 350, 600)];
    self.plot.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.plot];
    [self.plot release];
    
    self.plot.font = [UIFont systemFontOfSize:15];
    
    self.plot.numberOfLines = 0;
    

    
    
    
}

-(void)setAmovie:(Movielist *)amovie
{
    
    if (_amovie != amovie) {
        
        [_amovie release];
        _amovie = [amovie retain];
    }
//    self.navigationItem.title = self.amovie.title;
    self.grade.text = self.amovie.rating;
    self.runtime.text = self.amovie.runtime;
    self.data.text = self.amovie.release_date;
    self.country.text = self.amovie.country;
    self.genres.text = self.amovie.genres;
    self.actors.text = self.amovie.actors;
    self.plot.text = self.amovie.plot_simple;
    NSString *rating = [NSString stringWithFormat:@"(%@评论)",self.amovie.rating_count];
    self.rating_count.text = rating;
    [self.plot sizeToFit];
    [self.actors sizeToFit];
    
    
    
    
    NSURL *url = [NSURL URLWithString:self.amovie.pic_url];
    [self.headImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHoderImage"]];
    
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
